<template>
	<view>
		<!-- 轮播图 -->
		<swiper style="height: 600rpx;" next-margin="200rpx" current="1" circular="true" previous-margin="200rpx">
			<swiper-item class="swiper_item" v-for="(item,index) in swiper_list" :key="index" @click="detail(item.move_id)">
				<image :src="item.img" class="banner_img"></image>
				<text>{{item.movie_name}}</text>
			</swiper-item>
		</swiper>
		<!-- 最新的电影 -->
		<home-item :move_info="new_move"></home-item>
		<!-- 动漫电影 -->
		<home-item :move_info="animal_move"></home-item>
	</view>
</template>

<script>
	import homeItem from '../../components/homeItem/homeItem.vue'
	export default {
		components: {
			homeItem
		},

		data() {
			return {
				new_move: {
					title: "最新电影",
					move_list: ""
				},
				animal_move: {
					title: "动漫电影",
					move_list: ""
				},
				swiper_list: ""

			}
		},
		methods: {
			// 获取最新电影
			async getNewList() {
				let res = await uniCloud.callFunction({
					name: 'new_active'
				})
				this.new_move.move_list = res.result.data.slice(0, 3)
			},
			// 获取电影类型
			async getAnimal() {
				let res = await uniCloud.callFunction({
					name: "TypeList",
					data: {
						type: "动漫"
					}
				})
				console.log(res);
				this.animal_move.move_list = res.result.data.slice(0, 3)
			},
			// 获取轮播图
			async getSwiper() {
				let res = await uniCloud.callFunction({
					name: "swiper_list"
				})
				this.swiper_list = res.result.data
			},
			detail(id){
				console.log(id,123);
				uni.navigateTo({
					url:`../detail/detail?id=${id}`
				})
			}
		},
		onLoad() {
			this.getNewList()
			this.getAnimal()
			this.getSwiper()
		}
	}
</script>

<style scoped>
	.banner_img {
		width: 100%;
		height: 90%;
		margin: 0 30rpx;
	}

	.swiper_item {
		
		/* display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center; */
		text-align: center;
	}
</style>
